package com.wh.configurations;

import com.wh.interceptors.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Jetwang
 * @version 1.0
 * @since 2022/11/17 9:47
 */
//@Configuration
public class MvcConfig implements WebMvcConfigurer {

    @Bean
    public LoginInterceptor tokenInterceptor(){
        return new LoginInterceptor();
    }
    /**
     * 添加拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 将不需要携带token的请求排除在外
        registry.addInterceptor(tokenInterceptor()).excludePathPatterns(
                "/login/password",
                "/register",
                "/access-tokens",
                "/dep/all"
        );
    }
}
